package com.meilai.project.service.business.sale;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.meilai.project.dto.business.sale.*;
import com.meilai.project.entity.business.sale.BillSale;
import com.meilai.project.entity.business.sale.BillSaleGroup;
import com.meilai.project.entity.business.saleOrder.BillSaleAppendix;
import com.meilai.project.entity.media.MediaType;
import com.meilai.project.vo.business.installOrder.Id2PointIdVO;
import com.meilai.project.vo.business.sale.*;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author xchen
 * @since 2022-03-19
 */
public interface BillSaleService extends IService<BillSale> {

    List<Id2PointIdVO> listBillSaleMediaPoint(List<Long> billSaleIdList);

    List<MediaSpecTypeCountAmountVO> mediaTypeCountAmount(Long dateRangeId);

    Map<Long, List<MediaSpecTypeCountAmountVO>> mediaTypeCountAmountByIds(List<Long> dateRangeIds);

    // 获取列表
    Page<BillSaleVO> selectPageList(BillSaleListDTO searchDTO);

    List<BillSaleVO> listForMarketByContractId(Long contractId, Long mustIncludeBillSaleId, Integer type);

    // 获取调度查看的销售单列表
    Page<BillSaleVO2> dispatchList(BillSaleListDTO searchDTO);

    // 获取详情
    BillSaleVO getOneById(Long id);

    List<BillSaleVO> getListByIds(List<Long> ids);

    // 保存
    boolean save(BillSaleDTO dto);

    // 提交
    boolean begin(BillSaleDTO dto);

    // 通过
    boolean pass(BillSaleCheckDTO dto);

    // 驳回
    boolean returnBack(BillSaleCheckDTO dto);

    // 删除
    boolean delete(Long id);

    // 彻底删除
    boolean actualDelete(Long id);

    // 挂起
    void hangUpByChooseIds(List<Long> idList);

    void cancelHangUpByChooseIds(List<Long> idList);

    void invalidByChooseIds(List<Long> chooseIdList);

    List<BillSale> listByChooseIds(List<Long> chooseIdList);

    void update(Long oldContractId, Long newContractId);

    Boolean confirmMonitor(Long id);

    Boolean confirmGroupInvoiceReceive(Long id);

    Boolean uploadAppendix(List<BillSaleAppendix> appendixList);

    List<BillSaleAppendix> getAppendixListById(Long id);

    List<MediaType> getMediaTypeArrBySaleId(Long id);

    List<BillSaleVO> list_by_user_id(Long reimburse_id);

    CustomerCommissionVO get_customer_commission_by_sale_id(Long id, BigDecimal amount);


    boolean updateDate(LocalDate date, List<Long> ids);

    boolean updateReminderDate(LocalDate date, List<Long> ids);

    List<Long> getFullPaymentBillSaleIds();

    // 新建组别
    Boolean relation(BillSaleGroupDTO dto, Long user_id);

    // 获取分组列表（用于搜索），注意：user_id为null，获取所有
    List<BillSaleGroup> listGroup(Long user_id);

    //=============================NEW=============================
    Long begin(SaleBillDTO dto);

    Long save(SaleBillDTO dto);

    SaleBillVO getSingleById(Long id);

    Page<SaleBillVO> selectNewPageList(SaleBillListDTO searchDTO);

    BigDecimal getTotalExecutedAmount(Long contract_id);

    List<SaleBillVO> listLatestSaleBill(Long deptId, Long contractId, Long mustIncludeBillSaleId, Integer type);

}
